package com.android.launcher3;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

public class ApplicationsListAdapter extends ArrayAdapter<ApplicationInfo> {

	private final LayoutInflater mInflater;

	/**
	 * Creates a new ApplicationsListAdapter object.
	 * 
	 * @param paramContext
	 * @param paramArrayList
	 */
	public ApplicationsListAdapter(final Context paramContext,
			final ArrayList<ApplicationInfo> paramArrayList) {
		super(paramContext, 0, paramArrayList);

		LayoutInflater localLayoutInflater = LayoutInflater.from(paramContext);
		this.mInflater = localLayoutInflater;
	}

	public View getView(final int paramInt, View paramView,
			final ViewGroup paramViewGroup) {
		ApplicationInfo localApplicationInfo = (ApplicationInfo) getItem(paramInt);

		if (paramView == null) {
			paramView = this.mInflater.inflate(R.layout.application_listboxed,
					paramViewGroup, false);
		}

		LinearLayout localLinearLayout = (LinearLayout) paramView;
		TextView localTextView = (TextView) localLinearLayout
				.findViewById(R.id.name);
		localTextView.setText(localApplicationInfo.title);

		ImageView localImageView = (ImageView) localLinearLayout
				.findViewById(R.id.icon);
		localImageView.setImageDrawable(new FastBitmapDrawable(
				localApplicationInfo.iconBitmap));

		// String str1 = null;
		// String str2 = null;
		//
		// if ((localApplicationInfo.intent != null)
		// && (localApplicationInfo.intent.getComponent() != null)) {
		// str1 = localApplicationInfo.intent.getComponent().getPackageName();
		// str2 = localApplicationInfo.intent.getComponent().getClassName();
		// }
		//
		// Context localContext = getContext();
		// boolean bool = localApplicationInfo.systemApp;
		// Drawable localDrawable = Utilities.getDrawableIconBg(str1, str2,
		// localContext, bool);
		// localImageView.setBackgroundDrawable(localDrawable);
		paramView.setTag(localApplicationInfo);

		return paramView;
	}
}
